﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace DemoLib.Utilities.LoggingUtilities
{
    public  static class Log
    {
        public static void LogError(string message)
        {
            LogMessage(message, "Error", TraceEventType.Error);
        }

        public static void LogWarning(string message)
        {
            LogMessage(message, "Warning", TraceEventType.Warning);
        }

        public static void LogInformation(string message)
        {
            LogMessage(message, "Information", TraceEventType.Information);
        }

        public static void LogDebug(string message)
        {
            LogMessage(message, "Debug", TraceEventType.Verbose);
        }

        private static void LogMessage(string message, string category, TraceEventType eventType)
        {
            var logEntry = new LogEntry
            {
                Message = message,
                Severity = eventType,
                MachineName = Environment.MachineName,
                Categories = new List<string>() { category }
            };

            Logger.Write(logEntry);
        }
    }
}
